﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using infoMngmntGUI.View;
using infoMngmntGUI.Control;

namespace infoMngmntGUI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        #region Private Data Members
        private static MainWindow staticReference;
        private Controller controller;

        #endregion

        #region Construction

        /// <summary>
        /// 
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            controller = new Control.Controller();

            controller.CurrentUserControl += new Control.Controller.ChangeToUserControl(controller_CurrentUserControl);
            controller.AttemptToLoadControl(new Login(controller.AccessManager));
            staticReference = this;
        }

        #endregion

        #region Private Helper Methods / Evant Handlers

        /// <summary>
        /// 
        /// </summary>
        /// <param name="view"></param>
        void controller_CurrentUserControl(IView view)
        {
            contentFrame.Content = view;
            breadCrumbTextBox.Text = view.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addPatientButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new Add_Patient());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new Login(controller.AccessManager));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchPatientButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new Search_Patient());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void adminButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new Admin());
        }

        #endregion

        private void visitButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new AddVisit());
        }

        private void searchVisitButton_Click(object sender, RoutedEventArgs e)
        {
            controller.AttemptToLoadControl(new Search_Visit());
        }

        public static void DisplayOrderTest(int pID, int vID)
        {
            staticReference.controller.AttemptToLoadControl(new ViewAndOrderTests(pID, vID));
        }
    }
}
